//
//  BKMianXueFeiDataSource.m
//  baokaodaxue
//
//  Created by SKar on 15/6/2.
//  Copyright (c) 2015年 宏图教育. All rights reserved.
//

#import "BKMianXueFeiDataSource.h"
#import "BKMianXueFeiTableViewCell.h"

@interface BKMianXueFeiDataSource ()

@end

@implementation BKMianXueFeiDataSource



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if ([_dataArray isEqual:[NSNull null]]) {
        return 0;
    }
    
    if ([_dataArray isKindOfClass:[NSArray class]]) {
        return  [self.dataArray count];

    }
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    BKMianXueFeiTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:mianfei forIndexPath:indexPath];
    for (UIView *view in [cell.majorView subviews]) {
        [view removeFromSuperview];
    }
    NSDictionary *dic = self.dataArray[indexPath.row];
    cell.name.text = dic[@"name"];
    cell.xiangmu.text = dic[@"xiangmu"];
    
    NSArray *array = dic[@"major"];
    NSInteger num = [array count];
    cell.rows = num;
    for (int i=0; i<num; i++) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(1, i*44, tableView.frame.size.width/3-2, 44)];
        label.text = array[i][@"mname"];
        label.textAlignment = NSTextAlignmentCenter;
        if (i%2) {
            label.backgroundColor = [UIColor colorWithRed:0.910 green:0.965 blue:0.980 alpha:1.000];
            
        }else{
        
            label.backgroundColor = [UIColor clearColor];

            
        }
        
        [cell.majorView addSubview:label];
    
        
    }
    
    
    
    return cell;
}

@end
